home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Extensions… / Backwash ƒ / Backwash.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-20  |  5.1 KB  |  153 lines  |  [TEXT/MPS ]

  1. /*________________________________________________________
  2.  
  3.     File: Backwash.h
  4.     
  5.     Header file for a printing extension that adds a
  6.     QuickDraw picture to each page despooled.
  7.  
  8.     Dave Hersey
  9.     Apple Developer Technical Support
  10.  
  11.     11/11/92 - dmh - Created.
  12.      1/28/93 - dmh - Cleaned up for a5 seed CD.
  13.      3/26/93 - dmh - Updated for b1c2 (Translator changes).
  14.      8/24/93 - dmh - Updated for b2.
  15.               - The picture is now rolled into the spool
  16.                file as a resource, and applied to each
  17.                page during despooling.
  18.              - Added a TextEdit compatibility mode which
  19.                strips out the white rectangles drawn by
  20.                apps which use TextEdit to print (like
  21.                TeachText).
  22.              - The "intensity" panel item actually
  23.                functions now.
  24.              - Switched to Exception.h assertion stuff
  25.                for error checking.
  26.      9/09/93 - dmh - AddBackwash now displays progress info.
  27.     12/18/93 - dmh - Updated for b3.
  28.      3/22/94 - dmh - Updated for b4.
  29.  
  30.     (Note: there are labels in the Mark menu.)
  31.  
  32. __________________________________________________________*/
  33.  
  34. #include <Types.h>
  35. #include <Errors.h>
  36. #include <Dialogs.h>
  37. #include <Resources.h>
  38. #include <ToolUtils.h>
  39. #include <Collections.h>
  40. #include <Packages.h>
  41. #include <String.h>
  42. #include <StandardFile.h>
  43.  
  44. #pragma pointers_in_D0
  45. #include <GXExceptions.h>
  46. #include <GXMessages.h>
  47. #include <GXGraphics.h>
  48. #include <GXTypes.h>
  49. #include <GXEnvironment.h>
  50. #include <GXPrinting.h>
  51.  
  52.  
  53. #define kDontAddBackwash        0         /* backwash is turned on.            */
  54. #define kAddBackwash            1         /* backwash is turned off.            */
  55. #define kDefaultIntensity        40         /* default backwash intensity.        */
  56.  
  57. #define kCreator                'SpIT'      /* our creator type.                */
  58. #define kBackwashCollectionType    kCreator /* our collection type.            */
  59.  
  60.  
  61. /*    IDs of our user settings collection item and of the
  62.     spool file resource for our backwash picture.        */
  63.     
  64. #define kBackwashSettingsID        gxPrintingExtensionBaseID
  65. #define r_BackwashPICTID        gxPrintingExtensionBaseID +1
  66.  
  67. #define r_BackwashPanel            6000     /* our panel ID.                    */
  68.  
  69. #define d_Intensity                5         /* intensity of image.                */
  70. #define d_SelectPicture            7         /* "Select picture" button.        */
  71. #define d_FileNameItem            9         /* DITL item for filename to load.    */
  72.  
  73. #define r_BackwashStatus        1000     /* Our 'DLOG', 'DITL', and 'STR#'    */
  74.                                          /*    resources for displaying mssgs.    */
  75.  
  76. #define d_StatusFieldItem        1         /* DITL item for dialog text field.*/
  77.  
  78. #define s_StatusLoadPict        1         /* Indices to different status'    */
  79. #define s_ConvertPict            2         /* messages in our STR# resource.    */
  80. #define s_SetShapeIntensity        3
  81. #define s_SpoolShapeResource    4
  82. #define s_PictureNotLoaded        5
  83.  
  84. #define n_dlogLevel              .25        /* Level to display our dialogs at as a    */
  85.                                         /* percentage of the way down the        */
  86.                                         /* screen.  (See PositionWindow.)        */
  87.  
  88.  
  89. // This is what our collection looks like.  Notice the offsets below
  90. // agree with what we've said in our 'xdtl' resource.  This MUST be
  91. // the case.
  92.  
  93. typedef struct BackwashCollection
  94. {                                    // offset:
  95.     long            intensity;        //   0        brightness %
  96.     unsigned char    addBackwash;    //   4        is user adding a backwash?
  97.     unsigned char    useTextEditMode;//     5        use TextEdit compatibility mode?
  98.                                     //            (See routine RemoveWhiteRects.)
  99.     Boolean            haveFileInfo;    //            file chosen?
  100.     FSSpec            fileInfo;        //            info about the file chosen.
  101. } BackwashCollection;
  102.  
  103.  
  104. // This structure is used by the ShapeToHandle and HandleToShape routines.
  105.         
  106. typedef struct UserSpool
  107. {
  108.     gxSpoolBlock    spool;        // struct passed to gxFlattenShape & gxUnflattenShape.
  109.     long            position;    // byte offset in handle for next read or write.
  110.     long            size;        // handle size.
  111.     void            *data;        // the handle we're working with.
  112. } UserSpool;
  113.  
  114.  
  115. #define kAllocationIncrement    (40L *1024L)    /* Initial handle size for flattened shape.    */ 
  116.  
  117.  
  118. // This structure holds the instance-global data.
  119. typedef struct MyData
  120. {
  121.     gxShape            backwashShape;
  122. } MyDataRec, *MyDataPtr, **MyDataHdl ;
  123.  
  124.  
  125. // Function prototypes:
  126.  
  127. void            MyInitDataHandle(MyDataHdl dataHandle);
  128. gxShape            GetBackwashShape(void) ;
  129. OSErr            BWInitialize(void);
  130. OSErr            BWShutDown(void);
  131. OSErr            BWJobPrintDialog(gxDialogResult *dlogResult);
  132. OSErr            BWHandlePanelEvent(gxPanelInfoRecord *panelInfo);
  133. OSErr            BWCreateSpoolFile(FSSpecPtr anFSSpec, long createOptions,
  134.                                   gxSpoolFile *theSpoolFile);
  135. OSErr            BWCloseSpoolFile(gxSpoolFile theSpoolFile, long closeOptions);
  136. OSErr            BWDespoolPage(gxSpoolFile theSpoolFile, long thePageNum,
  137.                               gxFormat theFormat, gxShape *thePage,
  138.                               Boolean *formatChanged);
  139. OSErr            InitGlobalData(void);
  140. OSErr            SetUpPrintPanel(void);
  141. void            OpenBackwashPanel(DialogPtr pDlg, short itemCount);
  142. PicHandle        LoadAPict(FSSpecPtr opFSSpec);
  143. gxGraphicsError    AddBackwash(FSSpecPtr fileInfo, short theIntensity,
  144.                             gxSpoolFile theSpoolFile);
  145. gxGraphicsError    SetShapeIntensity(gxShape theShape, short theIntensity);
  146. Boolean            RemoveWhiteRects(gxShape theShape);
  147. OSErr            GetJobCollectionItem(void *collectItem, long *collectSize,
  148.                                         OSType collectType, short collectID);
  149. gxGraphicsError    HandleSpoolProc(gxSpoolCommand command, UserSpool *block);
  150. Handle            ShapeToHandle(gxShape source);
  151. gxShape            HandleToShape(Handle source, long count, const gxViewPort portList[]);
  152. void            PositionWindow(WindowPtr windPtr, Boolean showIt, float vertPercent);
  153.